<template>
	<el-button type="danger" :icon="Delete" circle @click="onClick"> </el-button>
</template>

<script setup lang="ts">
// 删除按钮
// 注意这个只能在 el-form-item绑定为数组的里面使用，不要放到内部的 el-form-item 里面去了
import { Delete } from '@element-plus/icons-vue'
import { useTrigger } from '@/utils/validate/validatorRules'
const props = withDefaults(
	defineProps<{
		list: Record<string, any>
		index?: number
	}>(),
	{}
)
const { emitTrigger } = useTrigger()
function onClick() {
	const { list, index } = props
	list.splice(index, 1)

	// 触发校验
	emitTrigger()
}
</script>
<style scoped lang="scss"></style>
